const lib2 = require("../lib/KdocsDriveV2");
const fs = require("fs");
const path = require("path");
const garbaseXlsx = require("../tool/garbage_xlsx")
// let rdsheet = garbaseXlsx.generateXlsx();
// fs.createReadStream(rdsheet).on("close", () => {
//   debugger
//   let sheet2 = garbaseXlsx.generateXlsx();
//   let rd = fs.readFile(sheet2, { flag: "r" },(e,d)=>{
//     debugger
//   })
// }).pipe(process.stdout);

// debugger
lib2.GetKdV2ByWpssid("V02SJuD-whLCRLjGvhRvzt-XML7uqlw00a146fce003d18ab1d").then(async o => {
  debugger
  // fs.createReadStream(path.join(__dirname, "../tmp/createssss.xlsx"), {
  //   end: 500 * 1024 + 1
  // }).pipe(fs.createWriteStream(path.join(__dirname,"../DUMMY/head.xlsx")));
  let kd = o.data.kdv2;
  let otest = await kd.app.uploadFilePlusSmallFileVersion(path.join(__dirname,"../tmp/TT.part1.rar"),0)
  let o_down = await kd.getDownloadInfo(77722778705);
  await kd.getSpaces()
  let o_path = await kd.getPath(77722778705);
  let o_list = await kd.getFilesListInFolder(77723428716);
  let o_his = await kd.getHistories(77722778705);
  let o_hisdown = await kd.getDownloadUrlByHistoryId(77721948733, 76675207348);
  let o_current_ver = await kd.getDownloadUrlOfFile(77721948733);
  let o_token = await kd.requestUploadToken();
  let o_token2 = await kd.getOfficeCsrfToken();
  // let o_upn = await kd.formUploadNormalFile(path.join(__dirname, "../DUMMY/mdf.txt"), 0, false);
  // let o_ufpsfv = await kd.app.uploadFilePlusSmallFileVersion(path.join(__dirname, "../DUMMY/mdf.txt"));
  let o_ufpsf2 = await kd.app.uploadFilePlusSmallFileVersion(path.join(__dirname, "../tmp/tmp.rar"));
  debugger
  let ofolder = await kd.createFolder("我是谁我在哪儿☆★");
  let odown2 = await kd.getDownloadByFver_OfficeApi(77720939596, 1);
  debugger
  let up1 = await kd.formUploadRarFileAsXlsx(path.join(__dirname, "../tmp/TT.part2.rar"));
  let up2 = await kd.formUploadRandomXlsx(up1.data.nameAsXlsx);
  let up3 = await kd.formUploadRandomXlsx(up1.data.nameAsXlsx);
  // let oP = await Promise.all([1, 2, 3].map(e => kd.formUploadRandomXlsx(up1.data.nameAsXlsx)))
  debugger
  let cf = await kd.createNewFile(up1.data.nameAsXlsx, up1.data.newfilename_sha1,
    up1.data.etag, up1.data.combineSize);
  let update = await kd.updateFileToNewVersion(cf.data.fileid, up3.data.etag, up3.data.newfilename_sha1,
    up3.data.size, 0);
  debugger

})